package com.yzlwb.web.controller.skt;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yzlwb.common.annotation.Log;
import com.yzlwb.common.core.controller.BaseController;
import com.yzlwb.common.core.domain.AjaxResult;
import com.yzlwb.common.enums.BusinessType;
import com.yzlwb.skt.domain.SktWayline;
import com.yzlwb.skt.service.ISktWaylineService;
import com.yzlwb.common.utils.poi.ExcelUtil;
import com.yzlwb.common.core.page.TableDataInfo;

/**
 * 司空-航线
 * 
 * @author wfy
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/skt/wayline")
public class SktWaylineController extends BaseController
{
    @Autowired
    private ISktWaylineService sktWaylineService;

    /**
     * 同步司空航线信息
     */
    @GetMapping("/getSaveWayline")
    public AjaxResult getSaveWayline()
    {
        int saveWay = sktWaylineService.getSaveWayline(getLoginUser().getUser().getDept().getTwoUserToken(),getDeptId(),getLoginUser().getUsername());
        return success(saveWay);
    }


    /**
     * 查询航线列表
     */
    @PreAuthorize("@ss.hasPermi('skt:wayline:list')")
    @GetMapping("/list")
    public TableDataInfo list(SktWayline sktWayline)
    {
        startPage();
        List<SktWayline> list = sktWaylineService.selectSktWaylineList(sktWayline);
        return getDataTable(list);
    }

    /**
     * 导出航线列表
     */
    @PreAuthorize("@ss.hasPermi('skt:wayline:export')")
    @Log(title = "航线", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SktWayline sktWayline)
    {
        List<SktWayline> list = sktWaylineService.selectSktWaylineList(sktWayline);
        ExcelUtil<SktWayline> util = new ExcelUtil<SktWayline>(SktWayline.class);
        util.exportExcel(response, list, "航线数据");
    }

    /**
     * 获取航线详细信息
     */
    //@PreAuthorize("@ss.hasPermi('skt:wayline:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sktWaylineService.selectSktWaylineById(id));
    }

    /**
     * 新增航线
     */
    //@PreAuthorize("@ss.hasPermi('skt:wayline:add')")
    @Log(title = "航线", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SktWayline sktWayline)
    {
        return toAjax(sktWaylineService.insertSktWayline(sktWayline));
    }

    /**
     * 修改航线
     */
    //@PreAuthorize("@ss.hasPermi('skt:wayline:edit')")
    @Log(title = "航线", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SktWayline sktWayline)
    {
        return toAjax(sktWaylineService.updateSktWayline(sktWayline));
    }

    /**
     * 删除航线
     */
    @PreAuthorize("@ss.hasPermi('skt:wayline:remove')")
    @Log(title = "航线", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sktWaylineService.deleteSktWaylineByIds(ids));
    }
}
